using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Devices.Sensors;

namespace amazingfishing.sprites
{
    public class Pan:Sprite
    {
        protected Accelerometer accelerometer;
        protected Vector2 rodPoint;
        protected float dragPower;

        public Pan(Texture2D _img, Point _frameSize, Point _sheetSize):base()
        {
            img = _img;
            position = new Vector2(240, 500);
            frameSize = _frameSize;
            sheetSize = _sheetSize;
            accelerometer = new Accelerometer();
            accelerometer.Start();
            dragPower = 0;
        }

        public Pan(Texture2D _img)
            : base(_img,new Vector2(240,500))
        {
            accelerometer = new Accelerometer();
            accelerometer.Start();
            dragPower = 0;
        }

        public Vector2 RodPoint
        {
            get
            {
                return rodPoint;
            }
            set
            {
                rodPoint = value;
            }
        }

        public override void Update(GameTime gameTime)
        {
            if (accelerometer.IsDataValid)
            {
                if (accelerometer.CurrentValue.Acceleration.X > 0.2)
                {
                    speed = new Vector2(10, 0);
                }
                else if (accelerometer.CurrentValue.Acceleration.X < -0.2)
                {
                    speed = new Vector2(-10, 0);
                }
                else
                {
                    speed = new Vector2(0, 0);
                }
            }
            rodPoint.X = position.X + 33;
            rodPoint.Y = position.Y + 4;
            base.Update(gameTime);
        }

        public float DragPower
        {
            set
            {
                dragPower = value;
            }
            get
            {
                return dragPower;
            }
        }
    }
}
